export default (ep, box, num = 100) => {
  /*调用方法如下：*/
  const boxA = $('.tab_conbox a')
  if (boxA.length > num) {
    $.jqtab = (tabtit, tab_conbox, event, zindex) => {
      $(tab_conbox)
        .find('li')
        .hide()
      $(tabtit)
        .find(`li:eq(${zindex})`)
        .addClass('active')
        .show()
      $(tab_conbox)
        .find(`li:eq(${zindex})`)
        .show()
      $(tabtit)
        .find('li')
        .bind(event, function() {
          $(this)
            .addClass('active')
            .siblings('li')
            .removeClass('active')
          var activeindex = $(tabtit)
            .find('li')
            .index(this)
          $(tab_conbox)
            .children()
            .eq(activeindex)
            .show()
            .siblings()
            .hide()
          return false
        })
    }
    const cur = parseInt(
      $('.tab_conbox')
        .find('a.cur')
        .attr('data-index')
    )
    const len = Math.floor(boxA.length / num + 1)
    const index = cur % num === 0 ? Math.floor(cur / num) - 1 : Math.floor(cur / num)
    const zindex = index >= 0 ? index : 0
    for (let i = 1; i <= len; i++) {
      const start = (i - 1) * num + 1
      const end = (i - 1) * num + num
      $('.ep-page').append(`<li>${start}-${end}</li>`)
    }
    boxA.each(function(i) {
      boxA.slice(i * num, i * num + num).wrapAll('<li class="tab_con"></li>')
    })
    $.jqtab(ep, box, 'click', zindex)
  }
}
